package org.wangzx.framework.security.encoder;

import org.apache.commons.lang.StringUtils;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * Created by WangZX on 2018/7/12.
 */
public class Md5PasswordEncoder implements PasswordEncoder{

    @Override
    public String encode(CharSequence charSequence) {
        try {
            return MD5Encoder.encode(charSequence.toString());
        } catch (Exception e) {
           return null;
        }
    }

    @Override
    public boolean matches(CharSequence charSequence, String s) {
        String passEncoder = encode(charSequence);
        return StringUtils.equals(passEncoder,s) ? true : false;
    }
}
